#include "HP6578_2Ceng.h"

//HP6578控制喷墨的函数 将数据映射到喷头上
/*********************************
*函数名称：HP6578_PrintData
*函数功能：6578 的喷头映射函数并且控制喷头喷墨
*输入参数：dat是存储数据的buf 不同的机器需要的数据长度不同  彩色机为27byte长度
*输出参数：none
**********************************/
void HP6578_PrintData(uint8_t*dat)
{
	uint16_t Pn	=	0;
    
    //提速补偿 高电平
    GPIO_SetBits(XM_STEP_PORT, XM_STEP_PIN);

	L6452_ChannelOutput(CHANNEL_A,1);
	Pn	|=	(u16)(dat[0]&0x1);
	Pn	|=	(u16)(dat[2]&0x4)>> 1;
	Pn	|=	(u16)(dat[5]&0x20)>> 3;
	Pn	|=	(u16)(dat[7]&0x80)>> 4;
	Pn	|=	(u16)(dat[9]&0x1)<< 4;
	Pn	|=	(u16)(dat[11]&0x4)<< 3;
	Pn	|=	(u16)(dat[14]&0x20)<< 1;
	Pn	|=	(u16)(dat[16]&0x80);
	Pn	|=	(u16)(dat[18]&0x1)<< 8;
	Pn	|=	(u16)(dat[20]&0x4)<< 7;
	Pn	|=	(u16)(dat[23]&0x20)<< 5;
	Pn	|=	(u16)(dat[25]&0x80)<< 4;
	L6452_PowerOutput(Pn);
	Pn=0;
	
	L6452_ChannelOutput(CHANNEL_A,2);
	Pn	|=	(u16)(dat[0]&0x20)>> 5;
	Pn	|=	(u16)(dat[2]&0x80)>> 6;
	Pn	|=	(u16)(dat[6]&0x4);
	Pn	|=	(u16)(dat[8]&0x10)>> 1;
	Pn	|=	(u16)(dat[9]&0x20)>> 1;
	Pn	|=	(u16)(dat[11]&0x80)>> 2;
	Pn	|=	(u16)(dat[15]&0x4)<< 4;
	Pn	|=	(u16)(dat[17]&0x10)<< 3;
	Pn	|=	(u16)(dat[18]&0x20)<< 3;
	Pn	|=	(u16)(dat[20]&0x80)<< 2;
	Pn	|=	(u16)(dat[24]&0x4)<< 8;
	Pn	|=	(u16)(dat[26]&0x10)<< 7;
	L6452_PowerOutput(Pn);
	Pn=0;
	
	L6452_ChannelOutput(CHANNEL_A,3);
	Pn	|=	(u16)(dat[1]&0x4)>> 2;
	Pn	|=	(u16)(dat[3]&0x10)>> 3;
	Pn	|=	(u16)(dat[4]&0x20)>> 3;
	Pn	|=	(u16)(dat[6]&0x80)>> 4;
	Pn	|=	(u16)(dat[10]&0x4)<< 2;
	Pn	|=	(u16)(dat[12]&0x10)<< 1;
	Pn	|=	(u16)(dat[13]&0x20)<< 1;
	Pn	|=	(u16)(dat[15]&0x80);
	Pn	|=	(u16)(dat[19]&0x4)<< 6;
	Pn	|=	(u16)(dat[21]&0x10)<< 5;
	Pn	|=	(u16)(dat[22]&0x20)<< 5;
	Pn	|=	(u16)(dat[24]&0x80)<< 4;
	L6452_PowerOutput(Pn);
	Pn=0;
	
	L6452_ChannelOutput(CHANNEL_A,4);
	Pn	|=	(u16)(dat[1]&0x80)>> 7;
	Pn	|=	(u16)(dat[4]&0x2);
	Pn	|=	(u16)(dat[5]&0x4);
	Pn	|=	(u16)(dat[7]&0x10)>> 1;
	Pn	|=	(u16)(dat[10]&0x80)>> 3;
	Pn	|=	(u16)(dat[13]&0x2)<< 4;
	Pn	|=	(u16)(dat[14]&0x4)<< 4;
	Pn	|=	(u16)(dat[16]&0x10)<< 3;
	Pn	|=	(u16)(dat[19]&0x80)<< 1;
	Pn	|=	(u16)(dat[22]&0x2)<< 8;
	Pn	|=	(u16)(dat[23]&0x4)<< 8;
	Pn	|=	(u16)(dat[25]&0x10)<< 7;
	L6452_PowerOutput(Pn);
	Pn=0;

    //提速补偿 低电平
    GPIO_ResetBits(XM_STEP_PORT, XM_STEP_PIN);
	
	L6452_ChannelOutput(CHANNEL_A,5);
	Pn	|=	(u16)(dat[0]&0x4)>> 2;
	Pn	|=	(u16)(dat[2]&0x10)>> 3;
	Pn	|=	(u16)(dat[5]&0x80)>> 5;
	Pn	|=	(u16)(dat[8]&0x2)<< 2;
	Pn	|=	(u16)(dat[9]&0x4)<< 2;
	Pn	|=	(u16)(dat[11]&0x10)<< 1;
	Pn	|=	(u16)(dat[14]&0x80)>> 1;
	Pn	|=	(u16)(dat[17]&0x2)<< 6;
	Pn	|=	(u16)(dat[18]&0x4)<< 6;
	Pn	|=	(u16)(dat[20]&0x10)<< 5;
	Pn	|=	(u16)(dat[23]&0x80)<< 3;
	Pn	|=	(u16)(dat[26]&0x2)<< 10;
	L6452_PowerOutput(Pn);
	Pn=0;
	
	L6452_ChannelOutput(CHANNEL_A,6);
	Pn	|=	(u16)(dat[0]&0x80)>> 7;
	Pn	|=	(u16)(dat[3]&0x2);
	Pn	|=	(u16)(dat[6]&0x10)>> 2;
	Pn	|=	(u16)(dat[8]&0x40)>> 3;
	Pn	|=	(u16)(dat[9]&0x80)>> 3;
	Pn	|=	(u16)(dat[12]&0x2)<< 4;
	Pn	|=	(u16)(dat[15]&0x10)<< 2;
	Pn	|=	(u16)(dat[17]&0x40)<< 1;
	Pn	|=	(u16)(dat[18]&0x80)<< 1;
	Pn	|=	(u16)(dat[21]&0x2)<< 8;
	Pn	|=	(u16)(dat[24]&0x10)<< 6;
	Pn	|=	(u16)(dat[26]&0x40)<< 5;
	L6452_PowerOutput(Pn);
	Pn=0;
	
	L6452_ChannelOutput(CHANNEL_A,7);
	Pn	|=	(u16)(dat[1]&0x10)>> 4;
	Pn	|=	(u16)(dat[3]&0x40)>> 5;
	Pn	|=	(u16)(dat[4]&0x80)>> 5;
	Pn	|=	(u16)(dat[7]&0x2)<< 2;
	Pn	|=	(u16)(dat[10]&0x10);
	Pn	|=	(u16)(dat[12]&0x40)>> 1;
	Pn	|=	(u16)(dat[13]&0x80)>> 1;
	Pn	|=	(u16)(dat[16]&0x2)<< 6;
	Pn	|=	(u16)(dat[19]&0x10)<< 4;
	Pn	|=	(u16)(dat[21]&0x40)<< 3;
	Pn	|=	(u16)(dat[22]&0x80)<< 3;
	Pn	|=	(u16)(dat[25]&0x2)<< 10;
	L6452_PowerOutput(Pn);
	Pn=0;
	
	L6452_ChannelOutput(CHANNEL_A,8);
	Pn	|=	(u16)(dat[2]&0x2)>> 1;
	Pn	|=	(u16)(dat[4]&0x8)>> 2;
	Pn	|=	(u16)(dat[5]&0x10)>> 2;
	Pn	|=	(u16)(dat[7]&0x40)>> 3;
	Pn	|=	(u16)(dat[11]&0x2)<< 3;
	Pn	|=	(u16)(dat[13]&0x8)<< 2;
	Pn	|=	(u16)(dat[14]&0x10)<< 2;
	Pn	|=	(u16)(dat[16]&0x40)<< 1;
	Pn	|=	(u16)(dat[20]&0x2)<< 7;
	Pn	|=	(u16)(dat[22]&0x8)<< 6;
	Pn	|=	(u16)(dat[23]&0x10)<< 6;
	Pn	|=	(u16)(dat[25]&0x40)<< 5;
	L6452_PowerOutput(Pn);
	Pn=0;

    //提速补偿 高电平
    GPIO_SetBits(XM_STEP_PORT, XM_STEP_PIN);
	
	L6452_ChannelOutput(CHANNEL_A,9);
	Pn	|=	(u16)(dat[0]&0x10)>> 4;
	Pn	|=	(u16)(dat[2]&0x40)>> 5;
	Pn	|=	(u16)(dat[6]&0x2)<< 1;
	Pn	|=	(u16)(dat[8]&0x8);
	Pn	|=	(u16)(dat[9]&0x10);
	Pn	|=	(u16)(dat[11]&0x40)>> 1;
	Pn	|=	(u16)(dat[15]&0x2)<< 5;
	Pn	|=	(u16)(dat[17]&0x8)<< 4;
	Pn	|=	(u16)(dat[18]&0x10)<< 4;
	Pn	|=	(u16)(dat[20]&0x40)<< 3;
	Pn	|=	(u16)(dat[24]&0x2)<< 9;
	Pn	|=	(u16)(dat[26]&0x8)<< 8;
	L6452_PowerOutput(Pn);
	Pn=0;
	
	L6452_ChannelOutput(CHANNEL_A,10);
	Pn	|=	(u16)(dat[1]&0x2)>> 1;
	Pn	|=	(u16)(dat[3]&0x8)>> 2;
	Pn	|=	(u16)(dat[4]&0x10)>> 2;
	Pn	|=	(u16)(dat[6]&0x40)>> 3;
	Pn	|=	(u16)(dat[10]&0x2)<< 3;
	Pn	|=	(u16)(dat[12]&0x8)<< 2;
	Pn	|=	(u16)(dat[13]&0x10)<< 2;
	Pn	|=	(u16)(dat[15]&0x40)<< 1;
	Pn	|=	(u16)(dat[19]&0x2)<< 7;
	Pn	|=	(u16)(dat[21]&0x8)<< 6;
	Pn	|=	(u16)(dat[22]&0x10)<< 6;
	Pn	|=	(u16)(dat[24]&0x40)<< 5;
	L6452_PowerOutput(Pn);
	Pn=0;
	
	L6452_ChannelOutput(CHANNEL_A,11);
	Pn	|=	(u16)(dat[1]&0x40)>> 6;
	Pn	|=	(u16)(dat[4]&0x1)<< 1;
	Pn	|=	(u16)(dat[5]&0x2)<< 1;
	Pn	|=	(u16)(dat[7]&0x8);
	Pn	|=	(u16)(dat[10]&0x40)>> 2;
	Pn	|=	(u16)(dat[13]&0x1)<< 5;
	Pn	|=	(u16)(dat[14]&0x2)<< 5;
	Pn	|=	(u16)(dat[16]&0x8)<< 4;
	Pn	|=	(u16)(dat[19]&0x40)<< 2;
	Pn	|=	(u16)(dat[22]&0x1)<< 9;
	Pn	|=	(u16)(dat[23]&0x2)<< 9;
	Pn	|=	(u16)(dat[25]&0x8)<< 8;
	L6452_PowerOutput(Pn);
	Pn=0;
	
	L6452_ChannelOutput(CHANNEL_A,12);
	Pn	|=	(u16)(dat[0]&0x2)>> 1;
	Pn	|=	(u16)(dat[2]&0x8)>> 2;
	Pn	|=	(u16)(dat[5]&0x40)>> 4;
	Pn	|=	(u16)(dat[8]&0x1)<< 3;
	Pn	|=	(u16)(dat[9]&0x2)<< 3;
	Pn	|=	(u16)(dat[11]&0x8)<< 2;
	Pn	|=	(u16)(dat[14]&0x40);
	Pn	|=	(u16)(dat[17]&0x1)<< 7;
	Pn	|=	(u16)(dat[18]&0x2)<< 7;
	Pn	|=	(u16)(dat[20]&0x8)<< 6;
	Pn	|=	(u16)(dat[23]&0x40)<< 4;
	Pn	|=	(u16)(dat[26]&0x1)<< 11;
	L6452_PowerOutput(Pn);
	Pn=0;

    //提速补偿 低电平
    GPIO_ResetBits(XM_STEP_PORT, XM_STEP_PIN);
	
	L6452_ChannelOutput(CHANNEL_A,13);
	Pn	|=	(u16)(dat[0]&0x40)>> 6;
	Pn	|=	(u16)(dat[3]&0x1)<< 1;
	Pn	|=	(u16)(dat[6]&0x8)>> 1;
	Pn	|=	(u16)(dat[8]&0x20)>> 2;
	Pn	|=	(u16)(dat[9]&0x40)>> 2;
	Pn	|=	(u16)(dat[12]&0x1)<< 5;
	Pn	|=	(u16)(dat[15]&0x8)<< 3;
	Pn	|=	(u16)(dat[17]&0x20)<< 2;
	Pn	|=	(u16)(dat[18]&0x40)<< 2;
	Pn	|=	(u16)(dat[21]&0x1)<< 9;
	Pn	|=	(u16)(dat[24]&0x8)<< 7;
	Pn	|=	(u16)(dat[26]&0x20)<< 6;
	L6452_PowerOutput(Pn);
	Pn=0;
	
	L6452_ChannelOutput(CHANNEL_B,1);
	Pn	|=	(u16)(dat[1]&0x8)>> 3;
	Pn	|=	(u16)(dat[3]&0x20)>> 4;
	Pn	|=	(u16)(dat[4]&0x40)>> 4;
	Pn	|=	(u16)(dat[7]&0x1)<< 3;
	Pn	|=	(u16)(dat[10]&0x8)<< 1;
	Pn	|=	(u16)(dat[12]&0x20);
	Pn	|=	(u16)(dat[13]&0x40);
	Pn	|=	(u16)(dat[16]&0x1)<< 7;
	Pn	|=	(u16)(dat[19]&0x8)<< 5;
	Pn	|=	(u16)(dat[21]&0x20)<< 4;
	Pn	|=	(u16)(dat[22]&0x40)<< 4;
	Pn	|=	(u16)(dat[25]&0x1)<< 11;
	L6452_PowerOutput(Pn);
	Pn=0;
	
	L6452_ChannelOutput(CHANNEL_B,2);
	Pn	|=	(u16)(dat[2]&0x1);
	Pn	|=	(u16)(dat[4]&0x4)>> 1;
	Pn	|=	(u16)(dat[5]&0x8)>> 1;
	Pn	|=	(u16)(dat[7]&0x20)>> 2;
	Pn	|=	(u16)(dat[11]&0x1)<< 4;
	Pn	|=	(u16)(dat[13]&0x4)<< 3;
	Pn	|=	(u16)(dat[14]&0x8)<< 3;
	Pn	|=	(u16)(dat[16]&0x20)<< 2;
	Pn	|=	(u16)(dat[20]&0x1)<< 8;
	Pn	|=	(u16)(dat[22]&0x4)<< 7;
	Pn	|=	(u16)(dat[23]&0x8)<< 7;
	Pn	|=	(u16)(dat[25]&0x20)<< 6;
	L6452_PowerOutput(Pn);
	Pn=0;
	
	L6452_ChannelOutput(CHANNEL_B,3);
	Pn	|=	(u16)(dat[0]&0x8)>> 3;
	Pn	|=	(u16)(dat[2]&0x20)>> 4;
	Pn	|=	(u16)(dat[6]&0x1)<< 2;
	Pn	|=	(u16)(dat[8]&0x4)<< 1;
	Pn	|=	(u16)(dat[9]&0x8)<< 1;
	Pn	|=	(u16)(dat[11]&0x20);
	Pn	|=	(u16)(dat[15]&0x1)<< 6;
	Pn	|=	(u16)(dat[17]&0x4)<< 5;
	Pn	|=	(u16)(dat[18]&0x8)<< 5;
	Pn	|=	(u16)(dat[20]&0x20)<< 4;
	Pn	|=	(u16)(dat[24]&0x1)<< 10;
	Pn	|=	(u16)(dat[26]&0x4)<< 9;
	L6452_PowerOutput(Pn);
	Pn=0;
	
	L6452_ChannelOutput(CHANNEL_B,4);
	Pn	|=	(u16)(dat[1]&0x1);
	Pn	|=	(u16)(dat[3]&0x4)>> 1;
	Pn	|=	(u16)(dat[6]&0x20)>> 3;
	Pn	|=	(u16)(dat[8]&0x80)>> 4;
	Pn	|=	(u16)(dat[10]&0x1)<< 4;
	Pn	|=	(u16)(dat[12]&0x4)<< 3;
	Pn	|=	(u16)(dat[15]&0x20)<< 1;
	Pn	|=	(u16)(dat[17]&0x80);
	Pn	|=	(u16)(dat[19]&0x1)<< 8;
	Pn	|=	(u16)(dat[21]&0x4)<< 7;
	Pn	|=	(u16)(dat[24]&0x20)<< 5;
	Pn	|=	(u16)(dat[26]&0x80)<< 4;
	L6452_PowerOutput(Pn);
	Pn=0;
	
	L6452_ChannelOutput(CHANNEL_B,5);
	Pn	|=	(u16)(dat[1]&0x20)>> 5;
	Pn	|=	(u16)(dat[3]&0x80)>> 6;
	Pn	|=	(u16)(dat[5]&0x1)<< 2;
	Pn	|=	(u16)(dat[7]&0x4)<< 1;
	Pn	|=	(u16)(dat[10]&0x20)>> 1;
	Pn	|=	(u16)(dat[12]&0x80)>> 2;
	Pn	|=	(u16)(dat[14]&0x1)<< 6;
	Pn	|=	(u16)(dat[16]&0x4)<< 5;
	Pn	|=	(u16)(dat[19]&0x20)<< 3;
	Pn	|=	(u16)(dat[21]&0x80)<< 2;
	Pn	|=	(u16)(dat[23]&0x1)<< 10;
	Pn	|=	(u16)(dat[25]&0x4)<< 9;
	L6452_PowerOutput(Pn);	
}



//HP6578打印测试
//打印测试
//彩色机给buff赋值
/***************************************************
*函数名称： HP6578_TwoLayerPrintTestMoveDataToBuf
*函数功能： 彩色机 2层将数据放到打印buf中
*输入参数： buf就是要打印的数据缓存
*输出参数： none
*******************************************************/
void HP6578_TwoLayerPrintTestMoveDataToBuf(uint8_t*buff,uint16_t x_cnt,uint16_t y_cnt)
{
	//buff赋初值
	for(uint8_t i = 0;i < HP6578_BYTES_OF_ONE_LINE;i++)
		buff[i]	=	0xff;
	//根据y_cnt 判断
	switch(y_cnt)
	{
		case 0:		//对buff赋值	黄色上半部分
			buff[0]	&=	0x00,buff[0+9]	&=	0x00,buff[0+9+9]	&=	0x00;
			buff[1] &=  0x00,buff[1+9]  &=  0x00,buff[1+9+9]    &=  0x00;
			buff[2] &=  0x00,buff[2+9]  &=  0x00,buff[2+9+9]    &=  0x00;
			buff[3] &=  0x00,buff[3+9]  &=  0x00,buff[3+9+9]    &=  0x00;
			buff[4] &=  0x0f,buff[4+9]  &=  0x00,buff[4+9+9]    &=  0x00;
			buff[5] &=  0xff,buff[5+9]  &=  0x00,buff[5+9+9]    &=  0x00;
			buff[6] &=  0xff,buff[6+9]  &=  0x00,buff[6+9+9]    &=  0x00;
			buff[7] &=  0xff,buff[7+9]  &=  0x00,buff[7+9+9]    &=  0x00;
			buff[8] &=  0xff,buff[8+9]  &=  0x00,buff[8+9+9]    &=  0x00;
			break;
        case 1:
        case 2:
        case 3:     //黄色全喷
			buff[0]	&=	0xff,buff[0+9]	&=	0x00,buff[0+9+9]	&=	0x00;
			buff[1] &=  0xff,buff[1+9]  &=  0x00,buff[1+9+9]    &=  0x00;
			buff[2] &=  0xff,buff[2+9]  &=  0x00,buff[2+9+9]    &=  0x00;
			buff[3] &=  0xff,buff[3+9]  &=  0x00,buff[3+9+9]    &=  0x00;
			buff[4] &=  0xff,buff[4+9]  &=  0x00,buff[4+9+9]    &=  0x00;
			buff[5] &=  0xff,buff[5+9]  &=  0x00,buff[5+9+9]    &=  0x00;
			buff[6] &=  0xff,buff[6+9]  &=  0x00,buff[6+9+9]    &=  0x00;
			buff[7] &=  0xff,buff[7+9]  &=  0x00,buff[7+9+9]    &=  0x00;
			buff[8] &=  0xff,buff[8+9]  &=  0x00,buff[8+9+9]    &=  0x00;
			break;
		case 4:		// 黄色喷上半部分 红色也开始喷下半部分 
			buff[0]	&=	0xff,buff[0+9]	&=	0x00,buff[0+9+9]	&=	0x00;
			buff[1] &=  0xff,buff[1+9]  &=  0x00,buff[1+9+9]    &=  0x00;
			buff[2] &=  0xff,buff[2+9]  &=  0x00,buff[2+9+9]    &=  0x00;
			buff[3] &=  0xff,buff[3+9]  &=  0x00,buff[3+9+9]    &=  0x00;
			buff[4] &=  0xf0,buff[4+9]  &=  0x0f,buff[4+9+9]    &=  0x00;
			buff[5] &=  0x00,buff[5+9]  &=  0xff,buff[5+9+9]    &=  0x00;
			buff[6] &=  0x00,buff[6+9]  &=  0xff,buff[6+9+9]    &=  0x00;
			buff[7] &=  0x00,buff[7+9]  &=  0xff,buff[7+9+9]    &=  0x00;
			buff[8] &=  0x00,buff[8+9]  &=  0xff,buff[8+9+9]    &=  0x00;
			break;
		case 5:		// 红色全喷
		case 6:
		case 7:
			buff[0]	&=	0x00,buff[0+9]	&=	0xff,buff[0+9+9]	&=	0x00;
			buff[1] &=  0x00,buff[1+9]  &=  0xff,buff[1+9+9]    &=  0x00;
			buff[2] &=  0x00,buff[2+9]  &=  0xff,buff[2+9+9]    &=  0x00;
			buff[3] &=  0x00,buff[3+9]  &=  0xff,buff[3+9+9]    &=  0x00;
			buff[4] &=  0x00,buff[4+9]  &=  0xff,buff[4+9+9]    &=  0x00;
			buff[5] &=  0x00,buff[5+9]  &=  0xff,buff[5+9+9]    &=  0x00;
			buff[6] &=  0x00,buff[6+9]  &=  0xff,buff[6+9+9]    &=  0x00;
			buff[7] &=  0x00,buff[7+9]  &=  0xff,buff[7+9+9]    &=  0x00;
			buff[8] &=  0x00,buff[8+9]  &=  0xff,buff[8+9+9]    &=  0x00;			
			break;
						
		case 8:		// 红色喷上半部分 蓝色也开始喷下半部分 
			buff[0]	&=	0x00,buff[0+9]	&=	0xff,buff[0+9+9]	&=	0x00;
			buff[1] &=  0x00,buff[1+9]  &=  0xff,buff[1+9+9]    &=  0x00;
			buff[2] &=  0x00,buff[2+9]  &=  0xff,buff[2+9+9]    &=  0x00;
			buff[3] &=  0x00,buff[3+9]  &=  0xff,buff[3+9+9]    &=  0x00;
			buff[4] &=  0x00,buff[4+9]  &=  0xf0,buff[4+9+9]    &=  0x0f;
			buff[5] &=  0x00,buff[5+9]  &=  0x00,buff[5+9+9]    &=  0xff;
			buff[6] &=  0x00,buff[6+9]  &=  0x00,buff[6+9+9]    &=  0xff;
			buff[7] &=  0x00,buff[7+9]  &=  0x00,buff[7+9+9]    &=  0xff;
			buff[8] &=  0x00,buff[8+9]  &=  0x00,buff[8+9+9]    &=  0xff;
			break;			
		case 9:		// 蓝色全喷
		case 10:
		case 11:
			buff[0]	&=	0x00,buff[0+9]	&=	0x00,buff[0+9+9]	&=	0xff;
			buff[1] &=  0x00,buff[1+9]  &=  0x00,buff[1+9+9]    &=  0xff;
			buff[2] &=  0x00,buff[2+9]  &=  0x00,buff[2+9+9]    &=  0xff;
			buff[3] &=  0x00,buff[3+9]  &=  0x00,buff[3+9+9]    &=  0xff;
			buff[4] &=  0x00,buff[4+9]  &=  0x00,buff[4+9+9]    &=  0xff;
			buff[5] &=  0x00,buff[5+9]  &=  0x00,buff[5+9+9]    &=  0xff;
			buff[6] &=  0x00,buff[6+9]  &=  0x00,buff[6+9+9]    &=  0xff;
			buff[7] &=  0x00,buff[7+9]  &=  0x00,buff[7+9+9]    &=  0xff;
			buff[8] &=  0x00,buff[8+9]  &=  0x00,buff[8+9+9]    &=  0xff;
			break;			
		case 12:	// 蓝色色喷上半部分 
			buff[0]	&=	0x00,buff[0+9]	&=	0x00,buff[0+9+9]	&=	0xff;
			buff[1] &=  0x00,buff[1+9]  &=  0x00,buff[1+9+9]    &=  0xff;
			buff[2] &=  0x00,buff[2+9]  &=  0x00,buff[2+9+9]    &=  0xff;
			buff[3] &=  0x00,buff[3+9]  &=  0x00,buff[3+9+9]    &=  0xff;
			buff[4] &=  0x00,buff[4+9]  &=  0x00,buff[4+9+9]    &=  0xf0;
			buff[5] &=  0x00,buff[5+9]  &=  0x00,buff[5+9+9]    &=  0x00;
			buff[6] &=  0x00,buff[6+9]  &=  0x00,buff[6+9+9]    &=  0x00;
			buff[7] &=  0x00,buff[7+9]  &=  0x00,buff[7+9+9]    &=  0x00;
			buff[8] &=  0x00,buff[8+9]  &=  0x00,buff[8+9+9]    &=  0x00;			
			break;		
		default :
			break;			
	}
	//偶数排
	if(y_cnt % 2	==	0)
	{
		//根据x_cnt 判断 HP6578_PRINT_TEST_X_CNT
		if(x_cnt < 29)
		{
			buff[0]	&=	0xff,buff[0+9]	&=	0x00,buff[0+9+9]	&=	0x00;
			buff[1] &=  0xff,buff[1+9]  &=  0x00,buff[1+9+9]    &=  0x00;
			buff[2] &=  0xff,buff[2+9]  &=  0x00,buff[2+9+9]    &=  0x00;
			buff[3] &=  0xff,buff[3+9]  &=  0x00,buff[3+9+9]    &=  0x00;
			buff[4] &=  0xff,buff[4+9]  &=  0x00,buff[4+9+9]    &=  0x00;
			buff[5] &=  0xff,buff[5+9]  &=  0x00,buff[5+9+9]    &=  0x00;
			buff[6] &=  0xff,buff[6+9]  &=  0x00,buff[6+9+9]    &=  0x00;
			buff[7] &=  0xff,buff[7+9]  &=  0x00,buff[7+9+9]    &=  0x00;
			buff[8] &=  0xff,buff[8+9]  &=  0x00,buff[8+9+9]    &=  0x00;				
		}
		else if((x_cnt < 58)&&(x_cnt >= 29))
		{
			buff[0]	&=	0xff,buff[0+9]	&=	0xff,buff[0+9+9]	&=	0x00;
			buff[1] &=  0xff,buff[1+9]  &=  0xff,buff[1+9+9]    &=  0x00;
			buff[2] &=  0xff,buff[2+9]  &=  0xff,buff[2+9+9]    &=  0x00;
			buff[3] &=  0xff,buff[3+9]  &=  0xff,buff[3+9+9]    &=  0x00;
			buff[4] &=  0xff,buff[4+9]  &=  0xff,buff[4+9+9]    &=  0x00;
			buff[5] &=  0xff,buff[5+9]  &=  0xff,buff[5+9+9]    &=  0x00;
			buff[6] &=  0xff,buff[6+9]  &=  0xff,buff[6+9+9]    &=  0x00;
			buff[7] &=  0xff,buff[7+9]  &=  0xff,buff[7+9+9]    &=  0x00;
			buff[8] &=  0xff,buff[8+9]  &=  0xff,buff[8+9+9]    &=  0x00;					
		}
		else if((x_cnt >= HP6578_PRINT_TEST_X_CNT - 58)&&(x_cnt < HP6578_PRINT_TEST_X_CNT - 29))
		{
			buff[0]	&=	0x00,buff[0+9]	&=	0xff,buff[0+9+9]	&=	0xff;
			buff[1] &=  0x00,buff[1+9]  &=  0xff,buff[1+9+9]    &=  0xff;
			buff[2] &=  0x00,buff[2+9]  &=  0xff,buff[2+9+9]    &=  0xff;
			buff[3] &=  0x00,buff[3+9]  &=  0xff,buff[3+9+9]    &=  0xff;
			buff[4] &=  0x00,buff[4+9]  &=  0xff,buff[4+9+9]    &=  0xff;
			buff[5] &=  0x00,buff[5+9]  &=  0xff,buff[5+9+9]    &=  0xff;
			buff[6] &=  0x00,buff[6+9]  &=  0xff,buff[6+9+9]    &=  0xff;
			buff[7] &=  0x00,buff[7+9]  &=  0xff,buff[7+9+9]    &=  0xff;
			buff[8] &=  0x00,buff[8+9]  &=  0xff,buff[8+9+9]    &=  0xff;					
		}
		else if(x_cnt >= HP6578_PRINT_TEST_X_CNT - 29)
		{
			buff[0]	&=	0x00,buff[0+9]	&=	0x00,buff[0+9+9]	&=	0xff;
			buff[1] &=  0x00,buff[1+9]  &=  0x00,buff[1+9+9]    &=  0xff;
			buff[2] &=  0x00,buff[2+9]  &=  0x00,buff[2+9+9]    &=  0xff;
			buff[3] &=  0x00,buff[3+9]  &=  0x00,buff[3+9+9]    &=  0xff;
			buff[4] &=  0x00,buff[4+9]  &=  0x00,buff[4+9+9]    &=  0xff;
			buff[5] &=  0x00,buff[5+9]  &=  0x00,buff[5+9+9]    &=  0xff;
			buff[6] &=  0x00,buff[6+9]  &=  0x00,buff[6+9+9]    &=  0xff;
			buff[7] &=  0x00,buff[7+9]  &=  0x00,buff[7+9+9]    &=  0xff;
			buff[8] &=  0x00,buff[8+9]  &=  0x00,buff[8+9+9]    &=  0xff;					
		}
	}
	//奇数排
	else
	{
		//根据x_cnt 判断 HP6578_PRINT_TEST_X_CNT
		if(x_cnt < 29)
		{
			buff[0]	&=	0x00,buff[0+9]	&=	0x00,buff[0+9+9]	&=	0xff;
			buff[1] &=  0x00,buff[1+9]  &=  0x00,buff[1+9+9]    &=  0xff;
			buff[2] &=  0x00,buff[2+9]  &=  0x00,buff[2+9+9]    &=  0xff;
			buff[3] &=  0x00,buff[3+9]  &=  0x00,buff[3+9+9]    &=  0xff;
			buff[4] &=  0x00,buff[4+9]  &=  0x00,buff[4+9+9]    &=  0xff;
			buff[5] &=  0x00,buff[5+9]  &=  0x00,buff[5+9+9]    &=  0xff;
			buff[6] &=  0x00,buff[6+9]  &=  0x00,buff[6+9+9]    &=  0xff;
			buff[7] &=  0x00,buff[7+9]  &=  0x00,buff[7+9+9]    &=  0xff;
			buff[8] &=  0x00,buff[8+9]  &=  0x00,buff[8+9+9]    &=  0xff;				
		}
		else if((x_cnt < 58)&&(x_cnt >= 29))
		{
			buff[0]	&=	0x00,buff[0+9]	&=	0xff,buff[0+9+9]	&=	0xff;
			buff[1] &=  0x00,buff[1+9]  &=  0xff,buff[1+9+9]    &=  0xff;
			buff[2] &=  0x00,buff[2+9]  &=  0xff,buff[2+9+9]    &=  0xff;
			buff[3] &=  0x00,buff[3+9]  &=  0xff,buff[3+9+9]    &=  0xff;
			buff[4] &=  0x00,buff[4+9]  &=  0xff,buff[4+9+9]    &=  0xff;
			buff[5] &=  0x00,buff[5+9]  &=  0xff,buff[5+9+9]    &=  0xff;
			buff[6] &=  0x00,buff[6+9]  &=  0xff,buff[6+9+9]    &=  0xff;
			buff[7] &=  0x00,buff[7+9]  &=  0xff,buff[7+9+9]    &=  0xff;
			buff[8] &=  0x00,buff[8+9]  &=  0xff,buff[8+9+9]    &=  0xff;					
		}
		else if((x_cnt >= HP6578_PRINT_TEST_X_CNT - 58)&&(x_cnt < HP6578_PRINT_TEST_X_CNT - 29))
		{
			buff[0]	&=	0xff,buff[0+9]	&=	0xff,buff[0+9+9]	&=	0x00;
			buff[1] &=  0xff,buff[1+9]  &=  0xff,buff[1+9+9]    &=  0x00;
			buff[2] &=  0xff,buff[2+9]  &=  0xff,buff[2+9+9]    &=  0x00;
			buff[3] &=  0xff,buff[3+9]  &=  0xff,buff[3+9+9]    &=  0x00;
			buff[4] &=  0xff,buff[4+9]  &=  0xff,buff[4+9+9]    &=  0x00;
			buff[5] &=  0xff,buff[5+9]  &=  0xff,buff[5+9+9]    &=  0x00;
			buff[6] &=  0xff,buff[6+9]  &=  0xff,buff[6+9+9]    &=  0x00;
			buff[7] &=  0xff,buff[7+9]  &=  0xff,buff[7+9+9]    &=  0x00;
			buff[8] &=  0xff,buff[8+9]  &=  0xff,buff[8+9+9]    &=  0x00;					
		}
		else if(x_cnt >= HP6578_PRINT_TEST_X_CNT - 29)
		{
			buff[0]	&=	0xff,buff[0+9]	&=	0x00,buff[0+9+9]	&=	0x00;
			buff[1] &=  0xff,buff[1+9]  &=  0x00,buff[1+9+9]    &=  0x00;
			buff[2] &=  0xff,buff[2+9]  &=  0x00,buff[2+9+9]    &=  0x00;
			buff[3] &=  0xff,buff[3+9]  &=  0x00,buff[3+9+9]    &=  0x00;
			buff[4] &=  0xff,buff[4+9]  &=  0x00,buff[4+9+9]    &=  0x00;
			buff[5] &=  0xff,buff[5+9]  &=  0x00,buff[5+9+9]    &=  0x00;
			buff[6] &=  0xff,buff[6+9]  &=  0x00,buff[6+9+9]    &=  0x00;
			buff[7] &=  0xff,buff[7+9]  &=  0x00,buff[7+9+9]    &=  0x00;
			buff[8] &=  0xff,buff[8+9]  &=  0x00,buff[8+9+9]    &=  0x00;					
		}				
	}
}


/***************************************************
*函数名称： HP6578_OneLayerPrintTestMoveDataToBuf
*函数功能： 彩色机  1层将数据放到打印buf中
*输入参数： buf就是要打印的数据缓存
*输出参数： none
*******************************************************/
void HP6578_OneLayerPrintTestMoveDataToBuf(uint8_t*buff,uint16_t x_cnt,uint16_t y_cnt)
{
	//buff赋初值
	for(uint8_t i = 0;i < HP6578_BYTES_OF_ONE_LINE;i++)
		buff[i]	=	0xff;
	//根据y_cnt 判断
	switch(y_cnt)
	{
		case 0:		//对buff赋值	只打印黄色
        case 1:
			buff[0]	&=	0xff,buff[0+9]	&=	0x00,buff[0+9+9]	&=	0x00;
			buff[1] &=  0xff,buff[1+9]  &=  0x00,buff[1+9+9]    &=  0x00;
			buff[2] &=  0xff,buff[2+9]  &=  0x00,buff[2+9+9]    &=  0x00;
			buff[3] &=  0xff,buff[3+9]  &=  0x00,buff[3+9+9]    &=  0x00;
			buff[4] &=  0xff,buff[4+9]  &=  0x00,buff[4+9+9]    &=  0x00;
			buff[5] &=  0xff,buff[5+9]  &=  0x00,buff[5+9+9]    &=  0x00;
			buff[6] &=  0xff,buff[6+9]  &=  0x00,buff[6+9+9]    &=  0x00;
			buff[7] &=  0xff,buff[7+9]  &=  0x00,buff[7+9+9]    &=  0x00;
			buff[8] &=  0xff,buff[8+9]  &=  0x00,buff[8+9+9]    &=  0x00;
			break;
		case 2:		// 只打印红色
        case 3:
			buff[0]	&=	0x00,buff[0+9]	&=	0xff,buff[0+9+9]	&=	0x00;
			buff[1] &=  0x00,buff[1+9]  &=  0xff,buff[1+9+9]    &=  0x00;
			buff[2] &=  0x00,buff[2+9]  &=  0xff,buff[2+9+9]    &=  0x00;
			buff[3] &=  0x00,buff[3+9]  &=  0xff,buff[3+9+9]    &=  0x00;
			buff[4] &=  0x00,buff[4+9]  &=  0xff,buff[4+9+9]    &=  0x00;
			buff[5] &=  0x00,buff[5+9]  &=  0xff,buff[5+9+9]    &=  0x00;
			buff[6] &=  0x00,buff[6+9]  &=  0xff,buff[6+9+9]    &=  0x00;
			buff[7] &=  0x00,buff[7+9]  &=  0xff,buff[7+9+9]    &=  0x00;
			buff[8] &=  0x00,buff[8+9]  &=  0xff,buff[8+9+9]    &=  0x00;
			break;
		case 4:	// 只打印蓝色
        case 5:
			buff[0]	&=	0x00,buff[0+9]	&=	0x00,buff[0+9+9]	&=	0xff;
			buff[1] &=  0x00,buff[1+9]  &=  0x00,buff[1+9+9]    &=  0xff;
			buff[2] &=  0x00,buff[2+9]  &=  0x00,buff[2+9+9]    &=  0xff;
			buff[3] &=  0x00,buff[3+9]  &=  0x00,buff[3+9+9]    &=  0xff;
			buff[4] &=  0x00,buff[4+9]  &=  0x00,buff[4+9+9]    &=  0xff;
			buff[5] &=  0x00,buff[5+9]  &=  0x00,buff[5+9+9]    &=  0xff;
			buff[6] &=  0x00,buff[6+9]  &=  0x00,buff[6+9+9]    &=  0xff;
			buff[7] &=  0x00,buff[7+9]  &=  0x00,buff[7+9+9]    &=  0xff;
			buff[8] &=  0x00,buff[8+9]  &=  0x00,buff[8+9+9]    &=  0xff;			
			break;
		default :
			break;			
	}
	if(y_cnt % 2	==	0)
	{
		//根据x_cnt 判断 HP6578_PRINT_TEST_X_CNT
		if(x_cnt < 29)
		{
			buff[0]	&=	0xff,buff[0+9]	&=	0x00,buff[0+9+9]	&=	0x00;
			buff[1] &=  0xff,buff[1+9]  &=  0x00,buff[1+9+9]    &=  0x00;
			buff[2] &=  0xff,buff[2+9]  &=  0x00,buff[2+9+9]    &=  0x00;
			buff[3] &=  0xff,buff[3+9]  &=  0x00,buff[3+9+9]    &=  0x00;
			buff[4] &=  0xff,buff[4+9]  &=  0x00,buff[4+9+9]    &=  0x00;
			buff[5] &=  0xff,buff[5+9]  &=  0x00,buff[5+9+9]    &=  0x00;
			buff[6] &=  0xff,buff[6+9]  &=  0x00,buff[6+9+9]    &=  0x00;
			buff[7] &=  0xff,buff[7+9]  &=  0x00,buff[7+9+9]    &=  0x00;
			buff[8] &=  0xff,buff[8+9]  &=  0x00,buff[8+9+9]    &=  0x00;				
		}
		else if((x_cnt < 58)&&(x_cnt >= 29))
		{
			buff[0]	&=	0xff,buff[0+9]	&=	0xff,buff[0+9+9]	&=	0x00;
			buff[1] &=  0xff,buff[1+9]  &=  0xff,buff[1+9+9]    &=  0x00;
			buff[2] &=  0xff,buff[2+9]  &=  0xff,buff[2+9+9]    &=  0x00;
			buff[3] &=  0xff,buff[3+9]  &=  0xff,buff[3+9+9]    &=  0x00;
			buff[4] &=  0xff,buff[4+9]  &=  0xff,buff[4+9+9]    &=  0x00;
			buff[5] &=  0xff,buff[5+9]  &=  0xff,buff[5+9+9]    &=  0x00;
			buff[6] &=  0xff,buff[6+9]  &=  0xff,buff[6+9+9]    &=  0x00;
			buff[7] &=  0xff,buff[7+9]  &=  0xff,buff[7+9+9]    &=  0x00;
			buff[8] &=  0xff,buff[8+9]  &=  0xff,buff[8+9+9]    &=  0x00;					
		}
		else if((x_cnt >= HP6578_PRINT_TEST_X_CNT - 58)&&(x_cnt < HP6578_PRINT_TEST_X_CNT - 29))
		{
			buff[0]	&=	0x00,buff[0+9]	&=	0xff,buff[0+9+9]	&=	0xff;
			buff[1] &=  0x00,buff[1+9]  &=  0xff,buff[1+9+9]    &=  0xff;
			buff[2] &=  0x00,buff[2+9]  &=  0xff,buff[2+9+9]    &=  0xff;
			buff[3] &=  0x00,buff[3+9]  &=  0xff,buff[3+9+9]    &=  0xff;
			buff[4] &=  0x00,buff[4+9]  &=  0xff,buff[4+9+9]    &=  0xff;
			buff[5] &=  0x00,buff[5+9]  &=  0xff,buff[5+9+9]    &=  0xff;
			buff[6] &=  0x00,buff[6+9]  &=  0xff,buff[6+9+9]    &=  0xff;
			buff[7] &=  0x00,buff[7+9]  &=  0xff,buff[7+9+9]    &=  0xff;
			buff[8] &=  0x00,buff[8+9]  &=  0xff,buff[8+9+9]    &=  0xff;					
		}
		else if(x_cnt >= HP6578_PRINT_TEST_X_CNT - 29)
		{
			buff[0]	&=	0x00,buff[0+9]	&=	0x00,buff[0+9+9]	&=	0xff;
			buff[1] &=  0x00,buff[1+9]  &=  0x00,buff[1+9+9]    &=  0xff;
			buff[2] &=  0x00,buff[2+9]  &=  0x00,buff[2+9+9]    &=  0xff;
			buff[3] &=  0x00,buff[3+9]  &=  0x00,buff[3+9+9]    &=  0xff;
			buff[4] &=  0x00,buff[4+9]  &=  0x00,buff[4+9+9]    &=  0xff;
			buff[5] &=  0x00,buff[5+9]  &=  0x00,buff[5+9+9]    &=  0xff;
			buff[6] &=  0x00,buff[6+9]  &=  0x00,buff[6+9+9]    &=  0xff;
			buff[7] &=  0x00,buff[7+9]  &=  0x00,buff[7+9+9]    &=  0xff;
			buff[8] &=  0x00,buff[8+9]  &=  0x00,buff[8+9+9]    &=  0xff;					
		}
	}
	//奇数排
	else
	{
		//根据x_cnt 判断 HP6578_PRINT_TEST_X_CNT
		if(x_cnt < 29)
		{
			buff[0]	&=	0x00,buff[0+9]	&=	0x00,buff[0+9+9]	&=	0xff;
			buff[1] &=  0x00,buff[1+9]  &=  0x00,buff[1+9+9]    &=  0xff;
			buff[2] &=  0x00,buff[2+9]  &=  0x00,buff[2+9+9]    &=  0xff;
			buff[3] &=  0x00,buff[3+9]  &=  0x00,buff[3+9+9]    &=  0xff;
			buff[4] &=  0x00,buff[4+9]  &=  0x00,buff[4+9+9]    &=  0xff;
			buff[5] &=  0x00,buff[5+9]  &=  0x00,buff[5+9+9]    &=  0xff;
			buff[6] &=  0x00,buff[6+9]  &=  0x00,buff[6+9+9]    &=  0xff;
			buff[7] &=  0x00,buff[7+9]  &=  0x00,buff[7+9+9]    &=  0xff;
			buff[8] &=  0x00,buff[8+9]  &=  0x00,buff[8+9+9]    &=  0xff;				
		}
		else if((x_cnt < 58)&&(x_cnt >= 29))
		{
			buff[0]	&=	0x00,buff[0+9]	&=	0xff,buff[0+9+9]	&=	0xff;
			buff[1] &=  0x00,buff[1+9]  &=  0xff,buff[1+9+9]    &=  0xff;
			buff[2] &=  0x00,buff[2+9]  &=  0xff,buff[2+9+9]    &=  0xff;
			buff[3] &=  0x00,buff[3+9]  &=  0xff,buff[3+9+9]    &=  0xff;
			buff[4] &=  0x00,buff[4+9]  &=  0xff,buff[4+9+9]    &=  0xff;
			buff[5] &=  0x00,buff[5+9]  &=  0xff,buff[5+9+9]    &=  0xff;
			buff[6] &=  0x00,buff[6+9]  &=  0xff,buff[6+9+9]    &=  0xff;
			buff[7] &=  0x00,buff[7+9]  &=  0xff,buff[7+9+9]    &=  0xff;
			buff[8] &=  0x00,buff[8+9]  &=  0xff,buff[8+9+9]    &=  0xff;					
		}
		else if((x_cnt >= HP6578_PRINT_TEST_X_CNT - 58)&&(x_cnt < HP6578_PRINT_TEST_X_CNT - 29))
		{
			buff[0]	&=	0xff,buff[0+9]	&=	0xff,buff[0+9+9]	&=	0x00;
			buff[1] &=  0xff,buff[1+9]  &=  0xff,buff[1+9+9]    &=  0x00;
			buff[2] &=  0xff,buff[2+9]  &=  0xff,buff[2+9+9]    &=  0x00;
			buff[3] &=  0xff,buff[3+9]  &=  0xff,buff[3+9+9]    &=  0x00;
			buff[4] &=  0xff,buff[4+9]  &=  0xff,buff[4+9+9]    &=  0x00;
			buff[5] &=  0xff,buff[5+9]  &=  0xff,buff[5+9+9]    &=  0x00;
			buff[6] &=  0xff,buff[6+9]  &=  0xff,buff[6+9+9]    &=  0x00;
			buff[7] &=  0xff,buff[7+9]  &=  0xff,buff[7+9+9]    &=  0x00;
			buff[8] &=  0xff,buff[8+9]  &=  0xff,buff[8+9+9]    &=  0x00;					
		}
		else if(x_cnt >= HP6578_PRINT_TEST_X_CNT - 29)
		{
			buff[0]	&=	0xff,buff[0+9]	&=	0x00,buff[0+9+9]	&=	0x00;
			buff[1] &=  0xff,buff[1+9]  &=  0x00,buff[1+9+9]    &=  0x00;
			buff[2] &=  0xff,buff[2+9]  &=  0x00,buff[2+9+9]    &=  0x00;
			buff[3] &=  0xff,buff[3+9]  &=  0x00,buff[3+9+9]    &=  0x00;
			buff[4] &=  0xff,buff[4+9]  &=  0x00,buff[4+9+9]    &=  0x00;
			buff[5] &=  0xff,buff[5+9]  &=  0x00,buff[5+9+9]    &=  0x00;
			buff[6] &=  0xff,buff[6+9]  &=  0x00,buff[6+9+9]    &=  0x00;
			buff[7] &=  0xff,buff[7+9]  &=  0x00,buff[7+9+9]    &=  0x00;
			buff[8] &=  0xff,buff[8+9]  &=  0x00,buff[8+9+9]    &=  0x00;					
		}				
	}
}

//彩色机打印一排刷
/***************************************************
*函数名称： HP6578_PrintOneLine
*函数功能： 将buf中的数据通过调用彩色机打印算法打印出来
*输入参数： buf就是要打印的数据缓存
*输出参数： none
*******************************************************/
void HP6578_PrintOneLine(uint8_t* buf)
{
	HP6578_PrintData(buf);
}




//6578打印程序
/************************彩色机打印****************************/


//彩色机计算图片大小
//输入参数为长和宽
//返回值为图片大小
/***************************************************
*函数名称： HP6578_MatchTheSizeOfPicture
*函数功能： 根据图片的长和宽计算图片总大小
*输入参数： ThePictureOfX_px：长度  ThePictureOfY_px：宽度
*输出参数： none
*返回值：	图片大小
*******************************************************/
uint32_t HP6578_MatchTheSizeOfPicture(uint16_t ThePictureOfX_px,uint16_t ThePictureOfY_px)
{
	uint32_t TheSizeOfPicture;
	//计算图片有多少个byte
    TheSizeOfPicture    =   ThePictureOfX_px * (ThePictureOfY_px / HP6578_INKCNT_OF_ONE_LINE) * (HP6578_INKCNT_OF_ONE_LINE / 8) * 3 * 2; 
	return  TheSizeOfPicture;
}



//定义中心变量 之所以定在这里是因为  每个墨盒有对应的中心位置 
static uint16_t HP6578_XCenter	=	5300;				//X默认值是5300
static uint16_t HP6578_YCenter	=	3250;				//X默认值是3250
//修改中心
/******************************
*函数名称：HP78_ModifCenter
*函数功能：修改中心值
*输入参数：X y
*输出参数：none
****************************/
void HP6578_ModifCenter(uint16_t x,uint16_t y)
{
	HP6578_XCenter	=	x;
	HP6578_YCenter	=	y;
}

//取出X中心
/******************
*函数名称：HP78_TakeOutXCenter
*函数功能：取出X中心
*输入参数：none
*输出参数：none
*******************/
uint16_t HP6578_TakeOutXCenter(void)
{
	return HP6578_XCenter;
}
//取出Y中心
/******************
*函数名称： HP78_TakeOutYCenter
*函数功能： 取出Y中心
*输入参数： none
*输出参数： none
*******************/
uint16_t HP6578_TakeOutYCenter(void)
{
	return HP6578_YCenter;
}


//彩色机将数据放到buf中
/************************************
*函数名称： HP6578_TakeOutDataFromRamToBuf
*函数功能： 从RAM中取出数据到buf
*输入参数： ram ：存储数据的地址
*输出参数： buf为为准备打印的缓存 彩色机buf为27bytes
************************************/
void HP6578_TakeOutDataFromRamToBuf(uint8_t *buf,uint8_t *ram)
{
	for(uint16_t i = 0;i < HP6578_BYTES_OF_ONE_LINE;i++)
		buf[i]	=	ram[i];
}

//清洗墨盒
/**********************************
*函数名称： HP6578_RinseInk
*函数功能： 清洗墨盒 
*输入参数： none
*输出参数： none
*备注    ： 喷头移动到接墨盒处，喷出一定量的墨水清洗喷头
************************************/
void HP6578_RinseInk(void)
{
    uint8_t buff[HP6578_BYTES_OF_ONE_LINE];
	//给buff赋初值
    for(uint8_t i = 0;i < HP6578_BYTES_OF_ONE_LINE;i++)
		buff[i]   =   0xff;    
    //移动到接墨盒位置
    MOTOR_XY_MoveToDot(HP6578_XM_RINSE_INK_POSITION,HP6578_YM_RINSE_INK_POSITION);
    //加热墨盒
    for(uint32_t i = 0;i < L6452_GetLongHeatCnt();i++)
    {
        L6452_HeatInk(1);
        delay_us(15);
    } 
    //喷墨清洗
    for(uint32_t i = 0;i < HP6578_RINSE_INK_JET;i++)
        HP6578_PrintOneLine(buff);   
}


//彩色机的打印驱动
/**********************************
*函数名称： HP6578_PrintDriver
*函数功能： 彩色机打印驱动 
*输入参数： ThePictureOfX_px ：X方向点数  
*			ThePictureOfY_px ：Y方向点数
*输出参数： none
************************************/
void HP6578_PrintDriver(uint16_t ThePictureOfX_px,uint16_t ThePictureOfY_px)
{
	//获取图片大小
	uint32_t PictureSize	=	HP6578_MatchTheSizeOfPicture(ThePictureOfX_px,ThePictureOfY_px);
	//XY 移动到起点位置
	uint16_t x_print_origin  =    ThePictureOfX_px / 2  * HP6578_STEPS_BETWEEN_TWO_POINTS + HP6578_XM_INCREASE_SPEED_STEP;
	if( x_print_origin 	<	HP6578_TakeOutXCenter())
		x_print_origin =  	HP6578_TakeOutXCenter() - x_print_origin ;
	else 
		x_print_origin =  0;							
	uint16_t y_print_origin  =    ThePictureOfY_px / 2 * HP6578_STEPS_BETWEEN_TWO_POINTS;
	if( y_print_origin	<	HP6578_TakeOutYCenter())
		y_print_origin 	= 	HP6578_TakeOutYCenter() - y_print_origin;
	else
		y_print_origin = 0;
    
    //计算起点
    if(x_print_origin   <   HP6578_XM_RINSE_INK_POSITION)
        x_print_origin  =   0;
    else
        x_print_origin  -=  HP6578_XM_RINSE_INK_POSITION;
    
    if(y_print_origin   <   HP6578_YM_RINSE_INK_POSITION)
        y_print_origin  =   0;
    else
        y_print_origin  -=  HP6578_YM_RINSE_INK_POSITION;
	
	uint8_t buffer[HP6578_BYTES_OF_ONE_LINE];
    uint16_t x_cnt;
    uint8_t x_dir_flag = FLAG_HIGH;
    uint32_t SzieOfDataPrinted	=	0;
	//每一排刷的数据量
	uint32_t datasizeofeachline = ThePictureOfX_px * HP6578_BYTES_OF_ONE_LINE;
    uint32_t pram_addr  =   0;
    
    //清洗墨盒    
    HP6578_RinseInk();     
	//移动到起点 此时XY轴不复位继续移动到指定位置
	MOTOR_XY_MoveToDot_NoReset(x_print_origin,y_print_origin);	
    XM_Enable();
    YM_Enable();     
	//死循环 当图片完全打印完后就直接返回函数
	while(1)
    {   
	    //取一排刷数据
		SRAM_ReadDate((uint8_t*)(RAM_GetDataBufAddr()),pram_addr,0,datasizeofeachline );
		pram_addr  =  pram_addr + datasizeofeachline;
        //加热300次 
        for(uint32_t m = 0;m < L6452_GetShortHeatCnt();m++)
        {
            L6452_HeatInk(1);
            delay_us(15);
         }        
        if (x_dir_flag == FLAG_HIGH)  //0,2,4, 6....
        {
			XM_Dir_Forward();
			x_dir_flag = FLAG_LOW;
            //X轴加速
            XM_IncreaseSpeed();
            for(x_cnt = ThePictureOfX_px;x_cnt > 0;x_cnt--)
			{   
				//到DMA缓存地址取27个byte到buffer中
                HP6578_TakeOutDataFromRamToBuf(buffer,(uint8_t*)(RAM_GetDataBufAddr() + (ThePictureOfX_px - x_cnt)*HP6578_BYTES_OF_ONE_LINE));
				HP6578_PrintOneLine(buffer);
                HP6578_PrintOneLine(buffer);    
                SzieOfDataPrinted   +=  HP6578_BYTES_OF_ONE_LINE; 
                //XM_ContinueRunStep(HP6578_XM_MOVE_TO_NEXT_ROW);
			}
            //X轴减速
            XM_ReduceSpeed();
			//判断是不是打印完成  如果已经打印的数据量大于等于数据总量则说明打印完成
			if(SzieOfDataPrinted	>=	PictureSize)			
			{
                XM_Disable();
                YM_Disable();                    
				return;
			}
			YM_Dir_Forward();
			//当一排打完后下降到另一排
			YM_ContinueRunStep(HP6578_YM_MOVE_TO_NEXT_ROW);
        }
        else
        {
			XM_Dir_Reverse();
			x_dir_flag = FLAG_HIGH;
            //X轴加速
            XM_IncreaseSpeed();            
            for(x_cnt = ThePictureOfX_px;x_cnt > 0;x_cnt--)
			{
                HP6578_TakeOutDataFromRamToBuf(buffer,(uint8_t*)(RAM_GetDataBufAddr() + (ThePictureOfX_px - x_cnt)*HP6578_BYTES_OF_ONE_LINE));
				HP6578_PrintOneLine(buffer); 
                HP6578_PrintOneLine(buffer);  
				SzieOfDataPrinted   +=  HP6578_BYTES_OF_ONE_LINE; 
                //XM_ContinueRunStep(HP6578_XM_MOVE_TO_NEXT_ROW);
			}
            //X轴减速
			XM_ReduceSpeed();
			//判断是不是打印完成  如果已经打印的数据量大于等于数据总量则说明打印完成
			if(SzieOfDataPrinted	>=	PictureSize)		
			{//完成接收
				XM_Disable();
				YM_Disable();
				return;
			}
			YM_Dir_Forward();			
			YM_ContinueRunStep(HP6578_YM_MOVE_TO_NEXT_ROW);				
        }
    }
}



//彩色机打印测试
/*************************
*函数名称： HP6578_PrintTestDriver
*函数功能： 彩色机打印测试驱动
*输入参数： none
*输出参数： none
*************************/
void HP6578_PrintTestDriver(void)
{
	uint8_t buff[HP6578_BYTES_OF_ONE_LINE];
	uint16_t x_print_origin	=	HP6578_X_ORIGIN;
	uint16_t y_print_origin	=	HP6578_Y_ORIGIN;	
	uint16_t x_cnt,y_cnt;
	uint8_t x_dir_flag = FLAG_HIGH;
	//给buff赋初值
    for(uint8_t i = 0;i < HP6578_BYTES_OF_ONE_LINE;i++)
		buff[i]   =   0xff;
    //计算起点
    if(x_print_origin   <   HP6578_XM_RINSE_INK_POSITION)
        x_print_origin  =   0;
    else
        x_print_origin  -=  HP6578_XM_RINSE_INK_POSITION;
    
    if(y_print_origin   <   HP6578_YM_RINSE_INK_POSITION)
        y_print_origin  =   0;
    else
        y_print_origin  -=  HP6578_YM_RINSE_INK_POSITION;
    
    //清洗墨盒    
    HP6578_RinseInk();
	//XY轴移动到起点
    MOTOR_XY_MoveToDot_NoReset(x_print_origin,y_print_origin);    
    //使能X轴电机
    XM_Enable();
	//使能Y轴电机
    YM_Enable();
	//进入打印循环   
    /****************YMC单层**************************/
    for(y_cnt = 0;y_cnt < 6;y_cnt++)
	{
		//加热300次 
		for(uint32_t m = 0;m < L6452_GetShortHeatCnt();m++)
		{
			L6452_HeatInk(1);
			delay_us(15);
		}
		//判断 奇数行还是偶数行
		if (x_dir_flag == FLAG_HIGH) 
        {
			x_dir_flag = FLAG_LOW;
			//x轴正向
			XM_Dir_Forward();	
			//X加速
			XM_IncreaseSpeed();
			for(x_cnt = 0;x_cnt < HP6578_PRINT_TEST_X_CNT;x_cnt++)//x轴方向6cm
			{    
				//对buff赋值	
                HP6578_OneLayerPrintTestMoveDataToBuf(buff,x_cnt,y_cnt);
				//打印一排刷
				HP6578_PrintOneLine(buff);
				HP6578_PrintOneLine(buff);
			}
			//X减速
			XM_ReduceSpeed();
			//确定Y轴方向
			YM_Dir_Forward();
			//当一排打完后下降到另一排
			YM_ContinueRunStep(HP6578_PRINT_TEST_YM_MOVE_TO_NEXT_ROW); 
		}
		else
		{
			x_dir_flag = FLAG_HIGH;
			//X轴反向
			XM_Dir_Reverse();	
			//X加速
			XM_IncreaseSpeed();
			for(x_cnt = 0;x_cnt < HP6578_PRINT_TEST_X_CNT;x_cnt++)//x轴方向6cm
			{    
				//对buff赋值		
                HP6578_OneLayerPrintTestMoveDataToBuf(buff,x_cnt,y_cnt);     
				//打印一排刷
				HP6578_PrintOneLine(buff);
				HP6578_PrintOneLine(buff);
			}
			//X减速
			XM_ReduceSpeed();
			//确定Y轴方向
			YM_Dir_Forward();
			//当一排打完后下降到另一排
			YM_ContinueRunStep(HP6578_PRINT_TEST_YM_MOVE_TO_NEXT_ROW); 						
		}
	}		
	/****************双叠YMC2层********************/
	/*
		打印双层黄 
		打印双层红
		打印双层蓝
		打印双层黑共需要y_cnt =17
	*/
    for(y_cnt = 0;y_cnt < 13;y_cnt++)
	{
		//加热300次 
		for(uint32_t m = 0;m < L6452_GetShortHeatCnt();m++)
		{
			L6452_HeatInk(1);
			delay_us(15);
		}
		//判断 奇数行还是偶数行
		if (x_dir_flag == FLAG_HIGH) 
        {
			x_dir_flag = FLAG_LOW;
			//x轴正向
			XM_Dir_Forward();	
			//X加速
			XM_IncreaseSpeed();
			for(x_cnt = 0;x_cnt < HP6578_PRINT_TEST_X_CNT;x_cnt++)//x轴方向6cm
			{    
				//对buff赋值	
				HP6578_TwoLayerPrintTestMoveDataToBuf(buff,x_cnt,y_cnt);  
				//打印一排刷
				HP6578_PrintOneLine(buff);
				HP6578_PrintOneLine(buff);
			}
			//X减速
			XM_ReduceSpeed();
			//确定Y轴方向
			YM_Dir_Forward();
			//当一排打完后下降到另一排
			YM_ContinueRunStep(HP6578_YM_MOVE_TO_NEXT_ROW); 
		}
		else
		{
			x_dir_flag = FLAG_HIGH;
			//X轴反向
			XM_Dir_Reverse();	
			//X加速
			XM_IncreaseSpeed();
			for(x_cnt = 0;x_cnt < HP6578_PRINT_TEST_X_CNT;x_cnt++)//x轴方向6cm
			{    
				//对buff赋值	
				HP6578_TwoLayerPrintTestMoveDataToBuf(buff,x_cnt,y_cnt);     
				//打印一排刷
				HP6578_PrintOneLine(buff);
				HP6578_PrintOneLine(buff);
			}
			//X减速
			XM_ReduceSpeed();
			//确定Y轴方向
			YM_Dir_Forward();
			//当一排打完后下降到另一排
			YM_ContinueRunStep(HP6578_YM_MOVE_TO_NEXT_ROW); 						
		}
	}			
}

//6578给buf赋值
/*************************
*函数名称： HP6578_MachineBurnInGiveDataToBuf
*函数功能： 彩色机老化程序 给buf赋值
*输入参数：        
*输出参数： none
*************************/
void HP6578_MachineBurnInGiveDataToBuf(uint8_t *buff,uint16_t x_cnt,uint16_t y_cnt,uint16_t x_max,uint16_t y_max)
{
	//buff赋初值
	for(uint8_t i = 0;i < HP6578_BYTES_OF_ONE_LINE;i++)
		buff[i]	=	0xff;
	//根据y_cnt 判断
	if(y_cnt == 0)
	{
		//如果是第一排只打印下半部分
		buff[0]	&=	0x00,buff[0+9]	&=	0x00,buff[0+9+9]	&=	0x00;
		buff[1] &=  0x00,buff[1+9]  &=  0x00,buff[1+9+9]    &=  0x00;
		buff[2] &=  0x00,buff[2+9]  &=  0x00,buff[2+9+9]    &=  0x00;
		buff[3] &=  0x00,buff[3+9]  &=  0x00,buff[3+9+9]    &=  0x00;
		buff[4] &=  0x0f,buff[4+9]  &=  0x0f,buff[4+9+9]    &=  0x0f;
		buff[5] &=  0xff,buff[5+9]  &=  0xff,buff[5+9+9]    &=  0xff;
		buff[6] &=  0xff,buff[6+9]  &=  0xff,buff[6+9+9]    &=  0xff;
		buff[7] &=  0xff,buff[7+9]  &=  0xff,buff[7+9+9]    &=  0xff;
		buff[8] &=  0xff,buff[8+9]  &=  0xff,buff[8+9+9]    &=  0xff;
	}
	else if(y_cnt == y_max)	
	{
		// 如果是最后一排 只打印上半部分
		buff[0]	&=	0xff,buff[0+9]	&=	0xff,buff[0+9+9]	&=	0xff;
		buff[1] &=  0xff,buff[1+9]  &=  0xff,buff[1+9+9]    &=  0xff;
		buff[2] &=  0xff,buff[2+9]  &=  0xff,buff[2+9+9]    &=  0xff;
		buff[3] &=  0xff,buff[3+9]  &=  0xff,buff[3+9+9]    &=  0xff;
		buff[4] &=  0xf0,buff[4+9]  &=  0xf0,buff[4+9+9]    &=  0xf0;
		buff[5] &=  0x00,buff[5+9]  &=  0x00,buff[5+9+9]    &=  0x00;
		buff[6] &=  0x00,buff[6+9]  &=  0x00,buff[6+9+9]    &=  0x00;
		buff[7] &=  0x00,buff[7+9]  &=  0x00,buff[7+9+9]    &=  0x00;
		buff[8] &=  0x00,buff[8+9]  &=  0x00,buff[8+9+9]    &=  0x00;
	}		
	if(y_cnt % 2	==	0)
	{
		//根据x_cnt 判断 HP6578_PRINT_TEST_X_CNT
		if(x_cnt < 29)
		{
			buff[0]	&=	0xff,buff[0+9]	&=	0x00,buff[0+9+9]	&=	0x00;
			buff[1] &=  0xff,buff[1+9]  &=  0x00,buff[1+9+9]    &=  0x00;
			buff[2] &=  0xff,buff[2+9]  &=  0x00,buff[2+9+9]    &=  0x00;
			buff[3] &=  0xff,buff[3+9]  &=  0x00,buff[3+9+9]    &=  0x00;
			buff[4] &=  0xff,buff[4+9]  &=  0x00,buff[4+9+9]    &=  0x00;
			buff[5] &=  0xff,buff[5+9]  &=  0x00,buff[5+9+9]    &=  0x00;
			buff[6] &=  0xff,buff[6+9]  &=  0x00,buff[6+9+9]    &=  0x00;
			buff[7] &=  0xff,buff[7+9]  &=  0x00,buff[7+9+9]    &=  0x00;
			buff[8] &=  0xff,buff[8+9]  &=  0x00,buff[8+9+9]    &=  0x00;				
		}
		else if((x_cnt < 58)&&(x_cnt >= 29))
		{
			buff[0]	&=	0xff,buff[0+9]	&=	0xff,buff[0+9+9]	&=	0x00;
			buff[1] &=  0xff,buff[1+9]  &=  0xff,buff[1+9+9]    &=  0x00;
			buff[2] &=  0xff,buff[2+9]  &=  0xff,buff[2+9+9]    &=  0x00;
			buff[3] &=  0xff,buff[3+9]  &=  0xff,buff[3+9+9]    &=  0x00;
			buff[4] &=  0xff,buff[4+9]  &=  0xff,buff[4+9+9]    &=  0x00;
			buff[5] &=  0xff,buff[5+9]  &=  0xff,buff[5+9+9]    &=  0x00;
			buff[6] &=  0xff,buff[6+9]  &=  0xff,buff[6+9+9]    &=  0x00;
			buff[7] &=  0xff,buff[7+9]  &=  0xff,buff[7+9+9]    &=  0x00;
			buff[8] &=  0xff,buff[8+9]  &=  0xff,buff[8+9+9]    &=  0x00;					
		}
		else if((x_cnt >= x_max - 58)&&(x_cnt < x_max - 29))
		{
			buff[0]	&=	0x00,buff[0+9]	&=	0xff,buff[0+9+9]	&=	0xff;
			buff[1] &=  0x00,buff[1+9]  &=  0xff,buff[1+9+9]    &=  0xff;
			buff[2] &=  0x00,buff[2+9]  &=  0xff,buff[2+9+9]    &=  0xff;
			buff[3] &=  0x00,buff[3+9]  &=  0xff,buff[3+9+9]    &=  0xff;
			buff[4] &=  0x00,buff[4+9]  &=  0xff,buff[4+9+9]    &=  0xff;
			buff[5] &=  0x00,buff[5+9]  &=  0xff,buff[5+9+9]    &=  0xff;
			buff[6] &=  0x00,buff[6+9]  &=  0xff,buff[6+9+9]    &=  0xff;
			buff[7] &=  0x00,buff[7+9]  &=  0xff,buff[7+9+9]    &=  0xff;
			buff[8] &=  0x00,buff[8+9]  &=  0xff,buff[8+9+9]    &=  0xff;					
		}
		else if(x_cnt >= x_max - 29)
		{
			buff[0]	&=	0x00,buff[0+9]	&=	0x00,buff[0+9+9]	&=	0xff;
			buff[1] &=  0x00,buff[1+9]  &=  0x00,buff[1+9+9]    &=  0xff;
			buff[2] &=  0x00,buff[2+9]  &=  0x00,buff[2+9+9]    &=  0xff;
			buff[3] &=  0x00,buff[3+9]  &=  0x00,buff[3+9+9]    &=  0xff;
			buff[4] &=  0x00,buff[4+9]  &=  0x00,buff[4+9+9]    &=  0xff;
			buff[5] &=  0x00,buff[5+9]  &=  0x00,buff[5+9+9]    &=  0xff;
			buff[6] &=  0x00,buff[6+9]  &=  0x00,buff[6+9+9]    &=  0xff;
			buff[7] &=  0x00,buff[7+9]  &=  0x00,buff[7+9+9]    &=  0xff;
			buff[8] &=  0x00,buff[8+9]  &=  0x00,buff[8+9+9]    &=  0xff;					
		}
	}
	//奇数排
	else
	{
		//根据x_cnt 判断 HP6578_PRINT_TEST_X_CNT
		if(x_cnt < 29)
		{
			buff[0]	&=	0x00,buff[0+9]	&=	0x00,buff[0+9+9]	&=	0xff;
			buff[1] &=  0x00,buff[1+9]  &=  0x00,buff[1+9+9]    &=  0xff;
			buff[2] &=  0x00,buff[2+9]  &=  0x00,buff[2+9+9]    &=  0xff;
			buff[3] &=  0x00,buff[3+9]  &=  0x00,buff[3+9+9]    &=  0xff;
			buff[4] &=  0x00,buff[4+9]  &=  0x00,buff[4+9+9]    &=  0xff;
			buff[5] &=  0x00,buff[5+9]  &=  0x00,buff[5+9+9]    &=  0xff;
			buff[6] &=  0x00,buff[6+9]  &=  0x00,buff[6+9+9]    &=  0xff;
			buff[7] &=  0x00,buff[7+9]  &=  0x00,buff[7+9+9]    &=  0xff;
			buff[8] &=  0x00,buff[8+9]  &=  0x00,buff[8+9+9]    &=  0xff;				
		}
		else if((x_cnt < 58)&&(x_cnt >= 29))
		{
			buff[0]	&=	0x00,buff[0+9]	&=	0xff,buff[0+9+9]	&=	0xff;
			buff[1] &=  0x00,buff[1+9]  &=  0xff,buff[1+9+9]    &=  0xff;
			buff[2] &=  0x00,buff[2+9]  &=  0xff,buff[2+9+9]    &=  0xff;
			buff[3] &=  0x00,buff[3+9]  &=  0xff,buff[3+9+9]    &=  0xff;
			buff[4] &=  0x00,buff[4+9]  &=  0xff,buff[4+9+9]    &=  0xff;
			buff[5] &=  0x00,buff[5+9]  &=  0xff,buff[5+9+9]    &=  0xff;
			buff[6] &=  0x00,buff[6+9]  &=  0xff,buff[6+9+9]    &=  0xff;
			buff[7] &=  0x00,buff[7+9]  &=  0xff,buff[7+9+9]    &=  0xff;
			buff[8] &=  0x00,buff[8+9]  &=  0xff,buff[8+9+9]    &=  0xff;					
		}
		else if((x_cnt >= x_max - 58)&&(x_cnt < x_max - 29))
		{
			buff[0]	&=	0xff,buff[0+9]	&=	0xff,buff[0+9+9]	&=	0x00;
			buff[1] &=  0xff,buff[1+9]  &=  0xff,buff[1+9+9]    &=  0x00;
			buff[2] &=  0xff,buff[2+9]  &=  0xff,buff[2+9+9]    &=  0x00;
			buff[3] &=  0xff,buff[3+9]  &=  0xff,buff[3+9+9]    &=  0x00;
			buff[4] &=  0xff,buff[4+9]  &=  0xff,buff[4+9+9]    &=  0x00;
			buff[5] &=  0xff,buff[5+9]  &=  0xff,buff[5+9+9]    &=  0x00;
			buff[6] &=  0xff,buff[6+9]  &=  0xff,buff[6+9+9]    &=  0x00;
			buff[7] &=  0xff,buff[7+9]  &=  0xff,buff[7+9+9]    &=  0x00;
			buff[8] &=  0xff,buff[8+9]  &=  0xff,buff[8+9+9]    &=  0x00;					
		}
		else if(x_cnt >= x_max - 29)
		{
			buff[0]	&=	0xff,buff[0+9]	&=	0x00,buff[0+9+9]	&=	0x00;
			buff[1] &=  0xff,buff[1+9]  &=  0x00,buff[1+9+9]    &=  0x00;
			buff[2] &=  0xff,buff[2+9]  &=  0x00,buff[2+9+9]    &=  0x00;
			buff[3] &=  0xff,buff[3+9]  &=  0x00,buff[3+9+9]    &=  0x00;
			buff[4] &=  0xff,buff[4+9]  &=  0x00,buff[4+9+9]    &=  0x00;
			buff[5] &=  0xff,buff[5+9]  &=  0x00,buff[5+9+9]    &=  0x00;
			buff[6] &=  0xff,buff[6+9]  &=  0x00,buff[6+9+9]    &=  0x00;
			buff[7] &=  0xff,buff[7+9]  &=  0x00,buff[7+9+9]    &=  0x00;
			buff[8] &=  0xff,buff[8+9]  &=  0x00,buff[8+9+9]    &=  0x00;					
		}				
	}
}


//HP6578老化程序
/*************************
*函数名称： HP6578_MachineBurnIn
*函数功能： 彩色机老化程序
*输入参数： none
*输出参数： none
*************************/
void HP6578_MachineBurnIn(void)
{
    //打印矩形 1138*1152
    //图片长和宽
    uint16_t ThePictureOfX_px   =   942;
    uint16_t ThePictureOfY_px   =   1080;    
	//XY 移动到起点位置
	uint16_t x_print_origin  =    ThePictureOfX_px / 2  * HP6578_STEPS_BETWEEN_TWO_POINTS + HP6578_XM_INCREASE_SPEED_STEP;
	if( x_print_origin 	<	HP6578_TakeOutXCenter())
		x_print_origin =  	HP6578_TakeOutXCenter() - x_print_origin ;
	else 
		x_print_origin =  0;							
	uint16_t y_print_origin  =    ThePictureOfY_px / 2 * HP6578_STEPS_BETWEEN_TWO_POINTS;
	if( y_print_origin	<	HP6578_TakeOutYCenter())
		y_print_origin 	= 	HP6578_TakeOutYCenter() - y_print_origin;
	else
		y_print_origin = 0;	
      
    //计算起点
    if(x_print_origin   <   HP6578_XM_RINSE_INK_POSITION)
        x_print_origin  =   0;
    else
        x_print_origin  -=  HP6578_XM_RINSE_INK_POSITION;
    
    if(y_print_origin   <   HP6578_YM_RINSE_INK_POSITION)
        y_print_origin  =   0;
    else
        y_print_origin  -=  HP6578_YM_RINSE_INK_POSITION;

	uint8_t buff[HP6578_BYTES_OF_ONE_LINE];
    uint16_t x_cnt,y_cnt,x_max,y_max;
    uint8_t x_dir_flag  =   FLAG_HIGH;
	x_max	=	ThePictureOfX_px;
	y_max	=	ThePictureOfY_px / 72 * 2 - 1;
    //清洗墨盒    
    HP6578_RinseInk(); 
	//XY轴移动到起点
    MOTOR_XY_MoveToDot_NoReset(x_print_origin,y_print_origin);
    //使能X轴电机
    XM_Enable();
	//使能Y轴电机
    YM_Enable();        
	//死循环 当图片完全打印完后就直接返回函数
	for(y_cnt = 0;y_cnt <= y_max;y_cnt++)
    {
        //加热300次 
        for(uint32_t m = 0;m < L6452_GetShortHeatCnt();m++)
        {
            L6452_HeatInk(1);
            delay_us(15);
        }
        if (x_dir_flag == FLAG_HIGH)  //0,2,4, 6....
        {
			XM_Dir_Forward();
			x_dir_flag  =   FLAG_LOW;
            //X轴加速
            XM_IncreaseSpeed();
            for(x_cnt = 0;x_cnt < x_max;x_cnt++)
			{
                //给buf赋值
                HP6578_MachineBurnInGiveDataToBuf(buff,x_cnt,y_cnt,x_max,y_max);
				HP6578_PrintOneLine(buff);
                HP6578_PrintOneLine(buff);    
			}
            //X轴减速
            XM_ReduceSpeed();
			//确定Y轴方向
			YM_Dir_Forward();
			//当一排打完后下降到另一排
			YM_ContinueRunStep(HP6578_YM_MOVE_TO_NEXT_ROW);
        }
        else
        {
			XM_Dir_Reverse();
			x_dir_flag = FLAG_HIGH;
            //X轴加速
            XM_IncreaseSpeed();            
            for(x_cnt = 0;x_cnt < x_max;x_cnt++)
			{
                //给buf赋值
                HP6578_MachineBurnInGiveDataToBuf(buff,x_cnt,y_cnt,x_max,y_max);
 				HP6578_PrintOneLine(buff); 
                HP6578_PrintOneLine(buff);  
			}
            //X轴减速
			XM_ReduceSpeed();
			YM_Dir_Forward();			
			YM_ContinueRunStep(HP6578_YM_MOVE_TO_NEXT_ROW);				
        }   
    }        
}

//自定义方法
/*************************
*函数名称： HP6578_DEFINE_Method_n
*函数功能： HP6578自定义方法
*输入参数： none
*输出参数： none
*************************/
void HP6578_DEFINE_Method_n(uint32_t Pparameter)
{
}


